package com.edu.exam.enums;

import com.edu.exam.enums.core.BaseEnum;

/**
 * 比较范围枚举
 *
 * 用于定义各种比较和查重操作的范围
 *
 * @author System
 * @version 1.0.0
 * @since 2025-11-13
 */
public enum ComparisonScope implements BaseEnum {
    SAME_COURSE("SAME_COURSE", "同课程"),
    SAME_SUBJECT("SAME_SUBJECT", "同科目"),
    SAME_DEPARTMENT("SAME_DEPARTMENT", "同院系"),
    SAME_MAJOR("SAME_MAJOR", "同专业"),
    SAME_CLASS("SAME_CLASS", "同班级"),
    SAME_TEACHER("SAME_TEACHER", "同教师"),
    SAME_SEMESTER("SAME_SEMESTER", "同学期"),
    SAME_ACADEMIC_YEAR("SAME_ACADEMIC_YEAR", "同学年"),
    ALL_PAPERS("ALL_PAPERS", "全部试卷"),
    ALL_QUESTIONS("ALL_QUESTIONS", "全部试题"),
    CUSTOM_SCOPE("CUSTOM_SCOPE", "自定义范围"),
    SYSTEM_WIDE("SYSTEM_WIDE", "系统范围");

    private final String code;
    private final String description;

    ComparisonScope(String code, String description) {
        this.code = code;
        this.description = description;
    }

    @Override
    public String getCode() {
        return code;
    }

    @Override
    public String getDescription() {
        return description;
    }

    public static ComparisonScope fromCode(String code) {
        for (ComparisonScope scope : values()) {
            if (scope.getCode().equals(code)) {
                return scope;
            }
        }
        throw new IllegalArgumentException("Unknown comparison scope code: " + code);
    }

    public static ComparisonScope fromDescription(String description) {
        for (ComparisonScope scope : values()) {
            if (scope.getDescription().equals(description)) {
                return scope;
            }
        }
        throw new IllegalArgumentException("Unknown comparison scope description: " + description);
    }

    @Override
    public String toString() {
        return code + " - " + description;
    }
}